package com.whale.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.whale.WebSocket.WebSocketServer;
import com.whale.constant.MessageConstant;
import com.whale.context.BaseContext;
import com.whale.dto.ReservePageQueryDTO;
import com.whale.dto.ReservePaymentDTO;
import com.whale.dto.ReserveSubmitDTO;
import com.whale.entity.Reserve;
import com.whale.entity.ReserveDetail;
import com.whale.entity.User;
import com.whale.entity.VenceOccupy;
import com.whale.exception.OrderBusinessException;
import com.whale.mapper.ReserveDetailMapper;
import com.whale.mapper.ReserveMapper;
import com.whale.mapper.UserMapper;
import com.whale.mapper.VenueOccupyMapper;
import com.whale.result.PageResult;
import com.whale.service.ReserveService;
import com.whale.service.VenueOccupyService;
import com.whale.utils.WeChatPayUtil;
import com.whale.vo.ReservePaymentVO;
import com.whale.vo.ReserveSubmitVO;
import com.whale.vo.ReserveVO;
import com.whale.vo.VenceOccupyVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Slf4j
public class VenueOccupyServiceImpl implements VenueOccupyService {

    @Autowired
    private VenueOccupyMapper venueOccupyMapper;
    /**
     * 查看所有占用场地详细
     */
   public List<VenceOccupyVO> allOccupy(){
       List<VenceOccupy> venceOccupyList=venueOccupyMapper.getAllDetail();
       List<VenceOccupyVO> venceOccupyVOList=new ArrayList<>();

       for(VenceOccupy venceOccupy:venceOccupyList){
           String[] split1=venceOccupy.getBeginTime().toString().split("T");
           String[] split2=venceOccupy.getEndTime().toString().split("T");
           String[] split3 = split1[1].split(":");
           String[] split4 = split2[1].split(":");
           String date=split1[0];
           String time = split3[0]+":"+split3[1]+"-"+split4[0]+":"+split4[1];
           VenceOccupyVO venceOccupyVO = new VenceOccupyVO();
           venceOccupyVO.setDate(date);
           venceOccupyVO.setTime(time);
           venceOccupyVO.setType(venceOccupy.getType());
           venceOccupyVO.setVenueNumber(venceOccupy.getVenueNumber());
           venceOccupyVOList.add(venceOccupyVO);
       }

        return venceOccupyVOList;
    }

}
